home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Nov. 24/97
- // Author: ajp
- //
- // Description:
- // doPlayblast is the actual proc that is executed from the
- // Windows->Playblast option box or menu
- //
- // Input Arguments:
- //
- // Return Value:
- // none
- //
-
- // This proc will generate a confirmation box. It is used when
- // a playblast file is about to be overwritten.
- //
- proc string confirmPlayblastOverwrite( string $type, string $filename )
- {
- string $message;
- string $showFilename;
-
- if (`exists Win32Init`)
- {
- $showFilename = unconvert($filename);
- }
- else
- {
- $showFilename = ($filename);
- }
-
- switch ($type) {
- case "sgi":
- $message = ("File \"" + $showFilename + "\" exists. Overwrite?");
- break;
- case "iff":
- $message = ("fcheck files exist with the prefix \""
- + $showFilename
- + "\" which may be overwritten. Continue?");
- break;
- case "qt":
- $message = ("File \"" + $showFilename + "\" exists. Overwrite?");
- break;
-
- default:
- $message = ("File \"" + $showFilename + "\" exists. Overwrite?");
- break;
- }
-
- string $result = `confirmDialog
- -t "Playblast Error: File Exists"
- -m $message
- -ma center
- -b "Ok"
- -b "Cancel"
- -db "Cancel"
- -cb "Cancel"
- -ds "Cancel"`;
- return $result;
- }
-
-
- // Creation Date: 11 Nov 98
- // Author: mw
- //
- // Description:
- // doPlayblastArgList allows for a variable number
- // or arguments to be passed in through a string array.
- // This is not possible through the fixed-arg proc doPlayblast
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : $whichRange, $timeRange, $option, $hierarchy,
- // $doControlPoints, $doShapes, $useChannelBox,
- // $selectionConnection
- // "2" : $options
- //
- // $args
- // Version 1
- // [0] $saveIt 0/1
- // [1] $movie name of movie if $saveIt is 1
- // [2] $isViewer 0/1
- // [3] $format sgi/iff
- // [4] $showOrnaments 0/1
- // [5] $scale scale source images by this amount
- // [6] $compression 0/1
- // [7] $displaySource what do we use to determine movie width/height
- // 1 : Use current view
- // 2 : Use Render Globals
- // 3 : Use values specified from option box
- // [8] $displayWidth requested width of movie
- // [9] $displayHeight requested height of movie
- //
- // Version 2
- // [10] $useStartEnd 0 : Use playback range (or highlighted range)
- // 1 : Use user-specified start/end
- // [11] $startTime time to start playblast
- // [12] $endTime time to end playblast
- //
- // Version 3
- // [13] $clearCache 0 : Leave previous temporary files
- // 1 : Delete temporary files from all previous
- // playblasts
- //
- // Return Value:
- // The number of curves from which keys were cut.
- //
- global proc doPlayblastArgList( string $versionStr, string $args[] )
- {
- int $version = $versionStr;
-
- string $saveIt = $args[0];
- string $movie = $args[1];
- int $isViewer = $args[2];
- string $format = $args[3];
- int $showOrnaments = $args[4];
- float $scale = $args[5];
- string $compression = $args[6];
- int $displaySource = $args[7];
- int $displayWidth = $args[8];
- int $displayHeight = $args[9];
-
- int $useStartEnd = ($version >= 2 ? $args[10] : 0);
- float $startTime = ($version >= 2 ? $args[11] : 1.0);
- float $endTime = ($version >= 2 ? $args[12] : 10.0);
-
- int $clearCache = ($version >= 3 ? $args[13] : 1);
-
- global string $gPlayBackSlider;
-
- string $cmd = "playblast ";
-
- // Use given start/end times
- //
- if( $useStartEnd ) {
- $cmd = ( $cmd+"-startTime "+$startTime+" -endTime "+$endTime + " " );
- }
- // Time range of the blast comes from Highlight, or playback
- // range if no highlight.
- //
- else {
- if( `timeControl -q -rangeVisible $gPlayBackSlider` ) {
- float $range[] = `timeControl -q -rangeArray $gPlayBackSlider`;
- // The range query returns the max value as the right edge
- // of the range. This is really one frame higher than we want
- // to playblast.
- //
- $cmd = ( $cmd + "-startTime " + $range[0] +
- " -endTime " + ($range[1] - 1.0) + " " );
- }
- }
-
- // if the "Save to File" flag is on and the
- // file already exists, we need to confirm if the
- // user wants to overwrite it
- //
- string $forceOverwriteFlag = "";
- if ( $saveIt ) {
-
- // the $movie string can be relative or absolute;
- // need to resolve it here
- //
- string $path = ""; // just the directory path
- string $filename = ""; // just the filename
-
- if ( substring($movie,1,1) != "/" && substring($movie,1,1) != "$"
- && (size($movie)>1 && substring($movie,2,2) != ":")) {
-
- // relative path, get the project's image directory
- //
- string $fileRules[] = `workspace -q -rt`;
- int $i;
- string $imageDir = ""; // default
- for ( $i = 0; $i < size($fileRules); $i += 2 ) {
- if ( $fileRules[$i] == "images" ) {
- $imageDir = $fileRules[$i+1];
- break;
- }
- }
- $path = (`workspace -q -fn` + "/" + $imageDir + "/");
- $filename = $movie;
-
- } else {
-
- // absolute path
- //
- int $index = 0;
- for( $index = size($movie); $index > 0; $index-- ) {
- if ( substring($movie,$index,$index) == "/"
- || substring($movie,$index,$index) == "$" ) {
- break;
- }
- }
-
- $path = substring($movie,1,$index);
- $filename = substring($movie,$index+1,size($movie));
- }
-
- if ( $format == "sgi" || $format == "qt" ) {
-
- // need to check for the ".mv" extension which
- // is added in the playblast code if it doesn't
- // already exist
- //
- string $tokens[];
- tokenize($filename,".",$tokens);
- if (`exists Win32Init`)
- {
- if ( $tokens[size($tokens)-1] != "avi" ) {
- $filename += ".avi";
- }
- }
- else if(`about -mac`)
- {
- if ( $tokens[size($tokens)-1] != "qt" ) {
- $filename += ".qt";
- }
- }
- else
- {
- if ( $tokens[size($tokens)-1] != "mv" ) {
- $filename += ".mv";
- }
- }
- // bring up a confirm dialog if the file already exists
- //
- if ( `file -q -exists ($path+$filename)` ) {
- string $result = `confirmPlayblastOverwrite sgi $movie`;
- if ( $result == "Ok" ) {
- $forceOverwriteFlag = " -forceOverwrite ";
- } else {
- return;
- }
- }
-
- } else {
-
- // need to check for files with this $movie as the
- // prefix and ending in ".iff"
- //
- int $i;
- string $regExp = ($filename+"\.*\.iff");
- string $dirListing[] = `workspace -l $path`;
- for ( $i = 0; $i < size($dirListing); $i++ ) {
- if ( match($regExp,$dirListing[$i]) != "" ) {
- // fcheck files exists with this prefix
- //
- string $result = `confirmPlayblastOverwrite iff $movie`;
- if ( $result == "Ok" ) {
- $forceOverwriteFlag = " -forceOverwrite ";
- break;
- } else {
- return;
- }
- }
- }
- }
- }
-
- // See if there's sound in the time slider
- //
- int $isSound = `timeControl -q -ds $gPlayBackSlider`;
- string $sound = `timeControl -q -s $gPlayBackSlider`;
-
- // convert old format flags to the new ones
- //
- if ($format == "sgi" || $format == "qt") $format = "movie";
- else $format = "image";
-
- // Output format
- //
- $cmd = ( $cmd + " -format " + $format );
-
- // If the time slider is displaying sound, use it.
- // Otherwise, don't.
- //
- // Fix for bug #141346
- // Was not playing sound with movies. It only playing sound if
- // $format=="sgi", but note that 11 lines up, if $format=="sgi"
- // we set $format to "movie".
- //
- if(( $format == "movie" )
- && ( $isSound )
- && ( size( $sound ) > 0 ) )
- {
- $cmd = ( $cmd + " -sound \"" + $sound + "\"" );
- }
-
- if( $saveIt ) {
- if( size( $movie ) > 0 ) {
- $cmd = ( $cmd + " -filename \"" + $movie + "\"" + $forceOverwriteFlag );
- } else {
- // We have to catch this error; otherwise it throws
- // up the call stack window.
- //
- if( catch( `error( "\"Save to file\" requires filename" )` ) ) {
- return;
- }
- }
- }
-
- // Clear cache
- //
- $cmd = ($cmd + " -clearCache " + $clearCache);
-
- // Add the viewer flag
- //
- $cmd = ( $cmd + " -viewer " + $isViewer );
-
- // Show ornaments
- //
- $cmd = ($cmd + " -showOrnaments " + $showOrnaments);
-
- // Add the percentage from our scale value
- //
- $cmd = ( $cmd + " -percent " +
- string( int( $scale * 100 ) ) );
-
- // Add the compression
- //
- if( $format == "movie" ) {
- $cmd = ( $cmd + " -compression " + $compression );
- }
-
- // Display size
- //
- switch ($displaySource) {
- case 1:
- break;
- case 3:
- $cmd = ($cmd + " -widthHeight " + $displayWidth + " " + $displayHeight);
- break;
- default:
- // Find the render globals
- //
- string $renderGlobals[] = `ls -type renderGlobals`;
- if (size ($renderGlobals) == 0) {
- warning ("Unable to find render globals");
- return;
- }
- string $connections[] = `listConnections $renderGlobals[0]`;
- if (size ($connections) == 0) {
- warning ("No resolution specified");
- return;
- }
- // Find the default resolution node
- //
- string $resolutionNode = "";
- for ($i = 0; $i < size ($connections); $i++) {
- if (`nodeType $connections[$i]` == "resolution") {
- $resolutionNode = $connections[$i];
- }
- }
- if (size ($resolutionNode) == 0) {
- warning ("No resolution specified");
- return;
- }
- int $resDisplayWidth = `getAttr ($resolutionNode + ".width")`;
- int $resDisplayHeight = `getAttr ($resolutionNode + ".height")`;
- $cmd = ($cmd+" -widthHeight "+$resDisplayWidth+" "+$resDisplayHeight);
- break;
- }
-
- evalEcho( $cmd );
- }
-